import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class TestDemo {

    public static List<Character> func(String str1,String str2) {
        List<Character> list = new ArrayList<>();
        for(int i = 0;i < str1.length();i++) {
            char ch = str1.charAt(i);
            if(!str2.contains(ch + "")) {//在str1中找到str2字符
                list.add(ch);
            }
        }
        return list;
    }
    public static void main(String[] args) {
        List<Character> ret = func("welcome to cvte","come");
        for(char ch : ret) {
            System.out.print(ch);
        }
    }
    public static void main3(String[] args) {
        //打印方式
        ArrayList<Integer> arrayList = new ArrayList<>();
        arrayList.add(10);
        arrayList.add(20);
        arrayList.add(30);
        arrayList.add(40);
        //1.直接打印
        System.out.println(arrayList);
        //2.for循环
        for(int i = 0;i < arrayList.size();i++) {
            System.out.print(arrayList.get(i) + " ");
        }
        System.out.println();
        //3.for each
        for(int x: arrayList) {
            System.out.print(x + " ");
        }
        System.out.println();
        //4.迭代器
        Iterator<Integer> it1 = arrayList.iterator();
        while(it1.hasNext()) {
            System.out.print(it1.next() + " ");
        }
        System.out.println();
        //5.
        ListIterator<Integer> it2 = arrayList.listIterator();
        while (it2.hasNext()) {
            System.out.print(it2.next()+" ");
        }
        System.out.println();
        //6、从后向前打印
        ListIterator<Integer> it3 =
                arrayList.listIterator(arrayList.size());
        while (it3.hasPrevious()) {
            System.out.print(it3.previous()+" ");
        }
        System.out.println();

    }
    public static void main2(String[] args) {
        //创建一个空顺序表
        ArrayList<Integer> arrayList1 = new ArrayList<>();
/*        ArrayList<Integer> arrayList2 = new ArrayList<>(10);
        arrayList2.add(10);
        arrayList2.add(20);
        arrayList2.add(30);
        arrayList2.add(40);
        System.out.println(arrayList2);
        ArrayList<Integer> arrayList3 = new ArrayList<>(arrayList2);
        arrayList3.add(999);
        System.out.println(arrayList3);*/
        arrayList1.add(10);
        arrayList1.add(20);
        arrayList1.add(30);
        arrayList1.add(40);
        ArrayList<Integer> arrayList4 = new ArrayList<>(arrayList1);
        List<Integer> arrayList = arrayList1.subList(0,2);
        System.out.println(arrayList);
        arrayList.set(0,99);
        System.out.println(arrayList);

    }
    public static void main1(String[] args) {
        MyArrayList myArrays = new MyArrayList();//实例化一个方法
        myArrays.add(1);
        myArrays.add(2);
        myArrays.add(3);
        myArrays.add(4);
        myArrays.add(5);
        myArrays.add(6);
//        System.out.println(myArrays.contains(5));
//        System.out.println(myArrays.indexOf(5));
        myArrays.remove(6);
        myArrays.display();
        myArrays.remove(1);
        myArrays.display();
        myArrays.remove(3);
        myArrays.display();
    }
}
